package com.hxzy.projectssmplus.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxzy.projectssmplus.dto.HousePlanningDTO;
import com.hxzy.projectssmplus.entity.HousePlanning;
import com.hxzy.projectssmplus.mapper.HousePlanningMapper;
import com.hxzy.projectssmplus.service.HousePlanningService;
import com.hxzy.projectssmplus.vo.HousePlanningVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;
import java.util.List;
@Service
public class HousePlanningServiceImpl extends ServiceImpl<HousePlanningMapper, HousePlanning> implements HousePlanningService {
    @Autowired
    private HousePlanningMapper housePlanningMapper;

    @Override
    public Integer planingDel(Long id) {

        int i = this.housePlanningMapper.deleteById(id);


        return i;
    }

    @Override
    public Integer planningAdd(HousePlanning housePlanning) {
        int i = this.housePlanningMapper.insert(housePlanning);

        return i;
    }

    @Override
    public Integer planningUpdate(HousePlanning housePlanning) {
        int i = this.housePlanningMapper.updateById(housePlanning);
        return i;
    }

    @Override
    public List<HousePlanningVo> seatchByXML(HousePlanningDTO housePlanningDTO) {
        List<HousePlanningVo> housePlannings = this.housePlanningMapper.seatchByXML(housePlanningDTO);
        return housePlannings;
    }

    @Override
    public Integer deleteByHouseId(Long houseId) {
        Integer integer = this.housePlanningMapper.deleteByHouseId(houseId);
        return integer;
    }

    @Override
    public HousePlanning planningOne(Long houseId) {
        QueryWrapper<HousePlanning> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("house_id",houseId);
        HousePlanning housePlanning = this.housePlanningMapper.selectOne(queryWrapper);
        return housePlanning;
    }
}
